package com.example.receiptocr.bodys.responseBodys

import android.os.Parcel
import android.os.Parcelable
import com.example.receiptocr.ocr.ReceiptData
import java.io.Serializable
import java.math.BigDecimal
import java.time.LocalDate

data class ReceiptInfo(
    val receiptId: Long,
    val receiptName: String? = null,
    val receiptCode: Long = 0,
    val receiptNumber: Long = 0,
    val receiptDate: String? = null,
    val purchaserName: String? = null,
    val purchaserCode: String? = null,
    val purchaserAddress: String? = null,
    val purchaserBank: String? = null,
    val sellerName: String? = null,
    val sellerCode: String? = null,
    val sellerAddress: String? = null,
    val sellerBank: String? = null,
    val totalAmount: Double? = null,
    val note: String? = null,
    val receiptDataList: List<ReceiptData> = listOf()
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readLong(),
        parcel.readString(),
        parcel.readLong(),
        parcel.readLong(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readValue(Double::class.java.classLoader) as? Double,
        parcel.readString(),
        parcel.createTypedArrayList(ReceiptData.CREATOR) ?: listOf()
    )

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeLong(receiptId)
        parcel.writeString(receiptName)
        parcel.writeLong(receiptCode)
        parcel.writeLong(receiptNumber)
        parcel.writeString(receiptDate)
        parcel.writeString(purchaserName)
        parcel.writeString(purchaserCode)
        parcel.writeString(purchaserAddress)
        parcel.writeString(purchaserBank)
        parcel.writeString(sellerName)
        parcel.writeString(sellerCode)
        parcel.writeString(sellerAddress)
        parcel.writeString(sellerBank)
        parcel.writeValue(totalAmount)
        parcel.writeString(note)
        parcel.writeTypedList(receiptDataList)
    }

    override fun describeContents() = 0

    companion object CREATOR : Parcelable.Creator<ReceiptInfo> {
        override fun createFromParcel(parcel: Parcel): ReceiptInfo = ReceiptInfo(parcel)
        override fun newArray(size: Int): Array<ReceiptInfo?> = arrayOfNulls(size)
    }
}
